<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    <a-spin :spinning="confirmLoading">
    <div class="table-box">
    <table>
    <tbody>
    <tr>
         <td> 申请单位</td>
         <td> <a-input v-model="formModel.sqdw" placeholder="请输入申请单位"></a-input></td>
         <td>申请岗位</td>
         <td colspan="3"><a-input v-model="formModel.sqgw" v-decorator="['sqgw']" placeholder="请输入申请岗位"></a-input></td>
    </tr>
    <tr>
        <td> 经办人</td>
        <td> <a-input v-model="formModel.jbren" v-decorator="['jbren']" placeholder="请输入经办人"></a-input></td>
        <td> 申请时间</td>
        <td><j-date v-model="formModel.sqdate" v-decorator="['sqdate']" placeholder="请输入申请时间" style="width:100%"  showTime dateFormat="YYYY-MM-DD"></j-date></td>
        <td> 岗位工资标准</td>
        <td> <a-input v-model="formModel.gwgzbz" v-decorator="['gwgzbz']" placeholder="请输入岗位工资标准"></a-input></td>
    </tr>
   <tr>
        <td rowspan="5">职位描述</td>
    </tr>
    <tr>
      <td colspan="5">请列出该职位前三项最主要的工作：</td>
    </tr>
     <tr>
         <td colspan="5"> <a-input v-model="formModel.zwms1" v-decorator="['zwms1']" placeholder="请输入职位描述1"></a-input></td>
     </tr>
  <tr>
         <td colspan="5"><a-input v-model="formModel.zwms2" v-decorator="['zwms2']" placeholder="请输入职位描述2"></a-input></td>
     </tr>
   <tr>
      <td colspan="5"><a-input v-model="formModel.zwms3" v-decorator="['zwms3']" placeholder="请输入职位描述3"></a-input></td>
    </tr>
      <tr>
       <td rowspan="9">拟招聘岗位要求</td>
      </tr>
       <tr>
            <td rowspan="9">任职资格：</td>
        </tr>
        <tr>
            <td colspan="4">具体描述：</td>
        </tr>
        <tr>
                    <td >人数：</td>
                    <td colspan="3"> <a-input v-model="formModel.rzzgRenshu" v-decorator="['rzzgRenshu']" placeholder="请输入人数"></a-input></td>
         </tr>
          <tr>
                     <td >年龄：</td>
                     <td colspan="3"> <a-input v-model="formModel.rzzgAge" v-decorator="['rzzgAge']" placeholder="请输入年龄"></a-input></td>
           </tr>
            <tr>
                    <td >性别：</td>
                     <td colspan="3"> <a-input v-model="formModel.rzzgSex" v-decorator="['rzzgSex']" placeholder="请输入性别"></a-input></td>
             </tr>
               <tr>
                    <td >学历：</td>
                      <td colspan="3"><a-input v-model="formModel.rzzgXl" v-decorator="['rzzgXl']" placeholder="请输入学历"></a-input></td>
                </tr>
               <tr>
                   <td >专业：</td>
                    <td colspan="3"><a-input v-model="formModel.rzzgZy" v-decorator="['rzzgZy']" placeholder="请输入专业"></a-input></td>
                 </tr>
                   <tr>
                      <td >经验：</td>
                      <td colspan="3"><a-input v-model="formModel.rzzgJy" v-decorator="['rzzgJy']" placeholder="请输入经验"></a-input></td>
                   </tr>
                   <tr>
                   </tr>
      <tr>
       <td >能力素质及其要求</td>
       <td colspan="5"> <a-input v-model="formModel.nlsz" v-decorator="['nlsz']" placeholder="请输入能力素质"></a-input></td>
      </tr>
       <tr>
          <td >招聘原因</td>
          <td colspan="5"><a-input v-model="formModel.zpyy" v-decorator="['zpyy']" placeholder="请输入招聘原因"></a-input></td>
       </tr>
        <tr>
             <td >用工期限</td>
             <td colspan="5">自<j-date v-model="formModel.ygstartdt" v-decorator="['ygstartdt']" placeholder="请输入用工开始时间"  showTime dateFormat="YYYY-MM-DD"></j-date>至<j-date v-model="formModel.ygenddt" v-decorator="['ygenddt']" placeholder="请输入用工结束时间"  showTime dateFormat="YYYY-MM-DD"></j-date></td>
         </tr>
    </tbody>
    </table>
    </div>
    </a-spin>
  </j-modal>
</template>

<script>

  import { httpAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import { validateDuplicateValue } from '@/utils/util'
  import JDate from '@/components/jeecg/JDate'  


  export default {
    name: "BjRecruitmentApplicationModal",
    components: { 
      JDate,
    },
    data () {
      return {
        form: this.$form.createForm(this),
        title:"操作",
        width:1400,
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        formModel:{},
        url: {
          add: "/bj/bjRecruitmentApplication/add",
          edit: "/bj/bjRecruitmentApplication/edit",
        }
      }
    },
    created () {
    console.log(this.form)
    },
    methods: {
      add () {
        this.edit({});
      },
      edit (record) {
        this.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
        this.$nextTick(() => {
        this.formModel=this.model;
          this.form.setFieldsValue(pick(this.model,'sqdw','sqgw','jbren','sqdate','gwgzbz','zwms1','zwms2','zwms3','rzzgRenshu','rzzgAge','rzzgSex','rzzgXl','rzzgZy','rzzgJy','nlsz','zpyy','ygstartdt','ygenddt','createBy','createTime','updateBy','updateTime'))
        })
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        const that = this;
        console.log(this.formModel)
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            let formData = Object.assign(this.model, values);
            console.log("表单提交数据",formData)
            httpAction(httpurl,formData,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }
         
        })
      },
      handleCancel () {
        this.close()
      },
      popupCallback(row){
        this.form.setFieldsValue(pick(row,'sqdw','sqgw','jbren','sqdate','gwgzbz','zwms1','zwms2','zwms3','rzzgRenshu','rzzgAge','rzzgSex','rzzgXl','rzzgZy','rzzgJy','nlsz','zpyy','ygstartdt','ygenddt','createBy','createTime','updateBy','updateTime'))
      },

      
    }
  }
</script>
<style>
.table-box table{
width:100%
}
.table-box tr td{
border:solid 1px #ccc;
padding:10px;
}
</style>
